#coding: utf-8

sh_a='http://biz.finance.sina.com.cn/stock/market_hq.php?type=61&by=symbol&order=asc'
sh_b='http://biz.finance.sina.com.cn/stock/market_hq.php?type=62&by=symbol&order=asc'
sz_a='http://biz.finance.sina.com.cn/stock/market_hq.php?type=63&by=symbol&order=asc'
sz_b='http://biz.finance.sina.com.cn/stock/market_hq.php?type=64&by=symbol&order=asc'

import urllib
from BeautifulSoup import BeautifulSoup
import select
import time

start=time.time()

print '解析中...'.decode('utf-8').encode('gbk')
ins=[urllib.urlopen(sh_a),urllib.urlopen(sh_b),urllib.urlopen(sz_a),urllib.urlopen(sz_b)]
try:
    i,o,e=select.select(ins,[],[])
    for x in i:
        page=x.read()
        soup=BeautifulSoup(page)
        for tr in soup.findAll('tr',{'align':'right'}):
            print tr.td.string,tr.td.nextSibling.a.string.encode('gbk')
except:
    pass
print time.time()-start